import random
import sys
if __name__ == '__main__':
    print("欢迎来到猜数字游戏")
    coin = 5000
    guess = int(input("请输入你猜的数字："))
    if guess > 0:
        num = random.randint(0,100)
        while coin > 0:
            if guess == num:
                print("你猜对了")
                coin=coin+3000
                print(coin)
                break
            elif guess > num:
                print("猜大了")
                coin=coin-500
                print(coin)
                guess = int(input("请输入你猜的数字："))
            else:
                print("猜小了")
                coin=coin-500
                print(coin)
                guess = int(input("请输入你猜的数字："))
        else:
            print("金币不足")
            sys.exit()
    else:
        print("输入的数字要在0-100之间")
        sys.exit()


